import 'package:citiesocial/_include.dart';

///
///有title有查看更多的控件
///
class TitleAndMore extends StatelessWidget {
  final String title, more;
  final List<Widget> children;
  final GestureTapCallback onMoreTap;

  TitleAndMore(
      {@required this.children, this.title, this.more = '看更多', this.onMoreTap})
      : super();

  @override
  Widget build(BuildContext context) {
    final widgets = List<Widget>();
    widgets.addAll([
      Container(
        child: Text(
          '$title',
          style: TextStyle(fontSize: 20.0, color: Colors.black),
        ),
        padding: EdgeInsets.all(10.0),
      ),
      Container(
        child: Configs.dividerMainColor,
        margin: EdgeInsets.symmetric(horizontal: 100.0),
      ),
    ]);
    if (children != null && children.length > 0) {
      widgets.addAll(children);
      widgets.addAll([
        Container(
          child: Configs.dividerMainColor,
          margin: EdgeInsets.symmetric(horizontal: 20.0),
        ),
        SeeMore(
          title: more,
          onTap: onMoreTap,
        ),
        Container(
          decoration: BoxDecoration(
              shape: BoxShape.rectangle, color: Configs.background),
          height: 10.0,
        ),
      ]);
    }
    return Container(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Center(
            child: Column(
              children: widgets,
            ),
          ),
        ],
      ),
      color: Colors.white,
    );
  }
}
